package com.enniu.alipay.api.data.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import com.alibaba.druid.pool.DruidDataSource;

@Configuration
public class DataSourceMaster {

	@Bean(name = "dataSource")
	@Qualifier("dataSource")
	public DataSource dataSource() {
		
		DruidDataSource dataSource = new DruidDataSource();
		dataSource.setDriverClassName(env
				.getProperty("spring.datasource.master.driver-class-name"));
		dataSource.setUrl(env.getProperty("spring.datasource.master.url"));
		dataSource.setUsername(env
				.getProperty("spring.datasource.master.username"));
		dataSource.setPassword(env
				.getProperty("spring.datasource.master.password"));
		return dataSource;
	}

	@Autowired
	private Environment env;
}